const path = require('path');
const fs = require('fs')

// 注意 ../ 会抵消前面的路径
// ./ 会被忽略
const pathStr = path.join('/a', '/b/c', '../../', './d', 'e')
console.log(pathStr) // \a\d\e

fs.readFile(path.join(__dirname,'../files/12345.txt'),'utf8',function(err,data){
    //console.log(data)
})
//修改文件名称  
/* fs.rename(path.join(__dirname,'./1.路径拼接.js'), path.join(__dirname,'./1.pathAll.js'), function(err){
    console.log(err); //null, 修改成功
}) */

// 定义文件的存放路径
const fpath = '/a/b/c/index.html'

const fullName = path.basename(fpath)
console.log(fullName) // index.html

const nameWithoutExt = path.basename(fpath, '.html')
console.log(nameWithoutExt) // index

const fext = path.extname(fpath)
console.log(fext) // .html